home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: network.com!news
- From: collim@anubis.network.com (Mike Collins)
- Subject: Processing a structure- how?
- X-Nntp-Posting-Host: collim.network.com
- Message-ID: <DnDv98.Ko1@network.com>
- Sender: news@network.com
- Organization: Network Systems Corporation
- X-Newsreader: WinVN 0.93.11
- Mime-Version: 1.0
- Date: Mon, 26 Feb 1996 12:41:31 GMT
-
- Folks,
-
- I want to write a generic routine that will print data contained
- in structures on the screen (of a DOS-based PC, but I don't think that
- comes into it). What I want is to be able to pass a structure or
- structure pointer to the routine, which will then be able to find out what
- the contents of the structure are, so that if I pass a customer structure
- containing surname, forename, address, phone number, I will be able to
- print this. If I pass a different structure containing catalog data, I
- will be able to print Item, category, bin location, etc.
-
- Is there a way for a function to find out how many fields are in a
- structure and what kind of variable each is (int, char[], etc)? I reallise
- that this information is known to the compiler and not to the compiled
- program as such, but can the compiler be made to embed information of this
- kind into a program?
-
- The effect would be like a printf() statement (I don't mind sending it a
- formatting string), but with only a structure or structure pointer as a
- data argument.
-
- Mike.
-
-